<?php

/**
 * This is the model class for table "{{promotton}}".
 *
 * The followings are the available columns in table '{{promotton}}':
 * @property integer $id
 * @property integer $zca_id
 * @property string $zpm_title
 * @property string $zpm_content
 * @property integer $zm_id
 * @property integer $zpm_start_time
 * @property integer $zpm_end_time
 * @property integer $zpm_type
 * @property integer $zmg_id
 */
class Promotton extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Promotton the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{promotton}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('zca_id, zpm_title, zm_id, zpm_start_time, zpm_end_time, zpm_type, zmg_id', 'required'),
			array('zca_id, zm_id, zpm_start_time, zpm_end_time, zpm_type, zmg_id', 'numerical', 'integerOnly'=>true),
			array('zpm_title', 'length', 'max'=>255),
			array('zpm_content', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, zca_id, zpm_title, zpm_content, zm_id, zpm_start_time, zpm_end_time, zpm_type, zmg_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'zca_id' => 'Zca',
			'zpm_title' => 'Zpm Title',
			'zpm_content' => 'Zpm Content',
			'zm_id' => 'Zm',
			'zpm_start_time' => 'Zpm Start Time',
			'zpm_end_time' => 'Zpm End Time',
			'zpm_type' => 'Zpm Type',
			'zmg_id' => 'Zmg',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('zca_id',$this->zca_id);
		$criteria->compare('zpm_title',$this->zpm_title,true);
		$criteria->compare('zpm_content',$this->zpm_content,true);
		$criteria->compare('zm_id',$this->zm_id);
		$criteria->compare('zpm_start_time',$this->zpm_start_time);
		$criteria->compare('zpm_end_time',$this->zpm_end_time);
		$criteria->compare('zpm_type',$this->zpm_type);
		$criteria->compare('zmg_id',$this->zmg_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}